package com.ambercrm.tools;

import android.os.Bundle;
import android.text.TextUtils;

import org.json.JSONArray;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author xu.wang
 * @desc 数据判空
 * @createtime 2018/12/27 17:19
 */
public class EmptyUtils {
    public static boolean isEmpty(String value) {
        return TextUtils.isEmpty(value);
    }

    public static boolean isEmpty(CharSequence value) {
        return TextUtils.isEmpty(value);
    }

    public static boolean isEmpty(Bundle bundle) {
        return bundle == null || bundle.isEmpty();
    }

    public static boolean isEmpty(List list) {
        return list == null || list.size() == 0;
    }

    public static boolean isEmpty(Map map) {
        return map == null || map.size() == 0;
    }

    public static boolean isEmpty(Set set) {
        return set == null || set.size() == 0;
    }

    public static boolean isEmpty(JSONArray jsonArray) {
        return jsonArray == null || jsonArray.length() == 0;
    }

    public static boolean isEmpty(Object[] objects) {
        return objects == null || objects.length == 0;
    }

    /***************************************************************************/

    public static boolean notEmpty(String value) {
        return !TextUtils.isEmpty(value);
    }

    public static boolean notEmpty(CharSequence value) {
        return !TextUtils.isEmpty(value);
    }

    public static boolean notEmpty(Bundle bundle) {
        return !isEmpty(bundle);
    }

    public static boolean notEmpty(List list) {
        return !isEmpty(list);
    }

    public static boolean notEmpty(Map map) {
        return !isEmpty(map);
    }

    public static boolean notEmpty(Set set){
        return !isEmpty(set);
    }

    public static boolean notEmpty(JSONArray jsonArray) {
        return !isEmpty(jsonArray);
    }

    public static boolean notEmpty(Object[] objects) {
        return !isEmpty(objects);
    }

}
